package com.likou.second_challenge;

import java.util.LinkedList;
import java.util.Queue;

public class q543 {

    int ans = 0;

    public int diameterOfBinaryTree(TreeNode root) {
        depth(root);
        return depth(root);
    }

    private int depth(TreeNode root) {
        if (root == null) {
            return 0;
        }

        int left = depth(root.left);
        int right = depth(root.right);
//        ans = Math.max(ans, left + right + 1);

        return Math.max(left, right) + 1;
    }
}
